package com.example.huadi1.service.Imp;

import com.example.huadi1.dto.Demand;
import com.example.huadi1.dto.Supplier;
import com.example.huadi1.mapper.SupplierMapper;
import com.example.huadi1.service.SupplierService;
import com.example.huadi1.utils.AjaxResult;
import com.example.huadi1.utils.PageUtils;
import com.example.huadi1.utils.Request.PageRequest;
import com.example.huadi1.utils.Request.SinglePageRequest;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class SupplierServiceImp implements SupplierService {
    @Autowired
    SupplierMapper supplierMapper;
    @Override
    public AjaxResult queryAllSupplier(SinglePageRequest singlePageRequest) {
        List<Supplier> suppliers = supplierMapper.selectAllSupplier();
        PageHelper.startPage(singlePageRequest.getPageNum(), singlePageRequest.getPageSize());
        PageInfo<Supplier> pageAll = PageInfo.of(suppliers);
        PageUtils pageUtils = new PageUtils(pageAll);
        AjaxResult result=AjaxResult.success(pageUtils);
        return result;
    }
}
